
#include "HistogramSettingsDialog.h"
#include "common.h"

//-------------------------------------

HistogramSettingsDialog::HistogramSettingsDialog( QWidget * parent ) :
    QDialog( parent )
{
    resize( 400, 300 );

    grdlMain = new QGridLayout( this );
    grdlMain->setContentsMargins( 0, 0, 0, 0 );

    lePath = new QLineEdit();
    btnChoose = new QPushButton();
    chbUseSpaces = new QCheckBox();

    sa = new QScrollArea();
    sa->setWidgetResizable( true );

    scrollContents = new QWidget();

    grdlFileSettings = new QGridLayout( scrollContents );
    grdlFileSettings->setContentsMargins( 0, 0, 0, 0 );

    lblFTitle = new QLabel();
    chbUseHrmNum = new QCheckBox();
    chbUseHrmFactor = new QCheckBox();

    grdlFileSettings->addWidget( lblFTitle,       0, 0, 1, 1 );
    grdlFileSettings->addWidget( chbUseHrmNum,    0, 1, 1, 1 );
    grdlFileSettings->addWidget( chbUseHrmFactor, 0, 2, 1, 1 );

    prepareFSGrid();

    sa->setWidget( scrollContents );
    //sa->resize( 200, 100 );

    buttonBox = new QDialogButtonBox( this );
    buttonBox->setOrientation( Qt::Horizontal );
    buttonBox->setStandardButtons( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );

    grdlMain->addWidget( lePath,       0, 0, 1, 1 );
    grdlMain->addWidget( btnChoose,    0, 1, 1, 1 );
    grdlMain->addWidget( chbUseSpaces, 1, 0, 1, 1 );
    grdlMain->addWidget( sa,           2, 0, 1, 2 );
    grdlMain->addWidget( buttonBox,    3, 0, 1, 2 );


    setWindowTitle( str8bit( "Histogram Settings Dialog" ) );
    btnChoose->setText( str8bit( "Choose Directory" ) );
    chbUseSpaces->setText( str8bit( "Use Spaces between Columns" ) );
    lblFTitle->setText( str8bit( "Harmonic file name" ) );
    chbUseHrmNum->setText( str8bit( "Use Harmonic number" ) );
    chbUseHrmFactor->setText( str8bit( "Use Factor" ) );

    setLayout( grdlMain );

    QObject::connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
    QObject::connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
}

//-------------------------------------

int HistogramSettingsDialog::Exec()
{
    int res = exec();
    if( res == QDialog::Accepted )
    {

    }
    return res;
}

//-------------------------------------

void HistogramSettingsDialog::prepareFSGrid()
{
    int cnt = 15;

    for( int i=0; i < cnt; i++ )
    {
        QLabel * lblName = new QLabel();
        QLineEdit * leHrmNum = new QLineEdit();
        QLineEdit * leF = new QLineEdit();

        grdlFileSettings->addWidget( lblName,  i+1, 0, 1, 1 );
        grdlFileSettings->addWidget( leHrmNum, i+1, 1, 1, 1 );
        grdlFileSettings->addWidget( leF,      i+1, 2, 1, 1 );

        lblName->setText( str8bit( "name %1" ).arg( i ) );

        HData hCtlItem;
        hCtlItem.lblName = lblName;
        hCtlItem.leHrmNum = leHrmNum;
        hCtlItem.leF = leF;

        hCtlList.push_back( hCtlItem );
    }
}

//-------------------------------------
